tests: Fix locale detection
authorJan Tojnar <jtojnar@gmail.com>
Sat, 2 Jun 2018 22:25:31 +0000 (00:25 +0200)
committerAtomic Bot <atomic-devel@projectatomic.io>
Sun, 3 Jun 2018 21:25:07 +0000 (21:25 +0000)
When a locale with C.utf8 in its name (e.g. es_EC.utf8) was installed
on a system, the C.utf8 locale was chosen, even when it was not available.

This patch fixes the grep pattern to match whole lines returned by locale -a.

See: #1592

Closes: #1611
Approved by: cgwalters

tests/libtest-core.sh

index 6991a86d4aef81cd43a2ade96f5d986a0040ec32..f6f94288fc615f17b702d3bea458db11f86c843f 100644 (file)
@@ -37,9 +37,9 @@ assert_not_reached () {
 # Some tests look for specific English strings. Use a UTF-8 version
 # of the C (POSIX) locale if we have one, or fall back to POSIX
 # (https://sourceware.org/glibc/wiki/Proposals/C.UTF-8)
-if locale -a | grep C.UTF-8 >/dev/null; then
+if locale -a | grep '^C.UTF-8$' >/dev/null; then
     export LC_ALL=C.UTF-8
-elif locale -a | grep C.utf8 >/dev/null; then
+elif locale -a | grep '^C.utf8$' >/dev/null; then
     export LC_ALL=C.utf8
 else
     export LC_ALL=C